This page last changed on Feb 05, 2010 by brian.

JEE JPA 2.0

Notes from

  • Automatic Orphan Deletion
    @Entity public class Order {
      @Id int orderId;
      ...
      @OneToMany(cascade=PERSIST, orphanRemoval=true)
      Set<Item> lineItems;
    }
  • Validation
    • Automatic validation upon lifecycle events: PrePersist, PreUpdate, PreRemove
    • Validation-mode element in persistence.xml: AUTO, CALLBACK, NONE
    • Example:
      @Entity public class Employee {
        @Id Integer id
        String name;
        @Max(15) Integer vacationDays;
        @Valid Address worksite;
        // ...
      }
      
      @Embeddable public class Address {
        @Size(max=30) String street;
        @Size(max=20) String city;
        @Zipcode String zipcode;
        // ...
      }
Document generated by Confluence on Feb 03, 2026 15:43